package com.xzl.management.controller;

import com.xzl.tool.util.RespBean;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @describe ：定时数据更新
 * @PageLocation:
 * @Auther xzl
 * @Date 2021/11/17 17:12
 */
@RestController
@Api("数据更新")
public class DatabaseController {
//    @Value("${filePath.sqlPath}")
//    private String sqlPath;
    @Value("${filePath.sqlName}")
    private String sqlName;

    @GetMapping("/test")
    public RespBean databasebackup(@RequestParam("sqlPath") String sqlPath){
        try {
            Process process = Runtime.getRuntime().exec(
                    "cmd  /c  mysqldump -u root -p123456 " + sqlName + " > "
                            + sqlPath + "/" + sqlName
                            + ".sql");

            return RespBean.success();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            return RespBean.error();
        }
    }
}
